<template>
  <el-config-provider :locale="zhCn" namespace="elp">
    <router-view></router-view>
  </el-config-provider>
</template>
<script setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import useEventBus from '@/use/use-event-bus.js'
import useChannel from '@/store/channel.js'
import { ElMessage } from 'element-plus'
import useFold from '@/store/fold'

const eventBus = useEventBus()
const channelStore = useChannel()
const router = useRouter()

const foldStore = useFold()

// 请求通知权限
if ('Notification' in window) {
  Notification.requestPermission().then((permission) => {
    if (permission === 'denied') {
      ElMessage.warning('您已拒绝通知权限,可能无法及时收到消息,如需通知可手动设置.')
    }
  })
}
eventBus.on('jumpChannel', (param) => {
  const channel = channelStore.channelList.find((i) => i.id === param.channelId)
  channelStore.setDialog(channel)
  router.push(`/chat?channelId=${param.channelId}`)
  foldStore.setHideChatContent(false)
  eventBus.emit('dialogScrollBottom')
})
</script>
